﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctManagementPower.ascx.cs" Inherits="KhoaLuan.MainSys.Manager.Controls.ctManagementPower" %>
<link href="/Style/StyleCommon.css" rel="stylesheet" />
<link href="/Style/modal.css" rel="stylesheet" />
<script src="/Scripts/dluscript.js"></script>
<script type="text/javascript">
    function LoadListArticles(totalitem, target, listArticles) {
        debugger;
        target.empty();
        listArticles.forEach(function (item) {
            var tr1 = $("<tr>");
            var btnexpand = CreateButton(item.GroupID, "fa-minus-square");
            btnexpand.attr('dataid', item.GroupID);
            btnexpand.css("margin-right", "5px");
            btnexpand.click(function () {
                if ($(this).hasClass('fa-plus')) {
                    var listtr = $('tr[dataid="' + $(this).attr('dataid') + '"');
                    listtr.css('display', 'visible');
                    $(this).removeClass('fa-plus')
                    $(this).addClass('fa-minus-square');
                }
                else {
                    var listtr = $('tr[dataid="' + $(this).attr('dataid') + '"');
                    listtr.css('display', 'none');
                    $(this).addClass('fa-plus')
                    $(this).removeClass('fa-minus-square');

                }
            });
            var btnedit = $('<a class="fa btn btn-xs btn-default fa-edit" style="float:right" href="/MainSys/Manager/ChangePermission.aspx?GroupID=' + item.GroupID + '">');
            var td1 = $("<td colSpan='6' style='background: gray;font-weight: bold;color: white;'>").append(btnexpand).append(btnedit).append(item.GroupName).append(' (' + item.ListControl.length + " function)");
            tr1.append(td1);
            target.append(tr1);
            if (item.ListControl.length == 0) {
                tr1 = $('<tr>').attr('dataid', item.GroupID);
                td1 = $("<td colSpan='6' style='text-align:center'>").append("Hiện tại chưa có quyền nào đối với các control");
                tr1.append(td1);
                target.append(tr1);
            }
            item.ListControl.forEach(function (item2) {
                var tr2 = $('<tr>').attr('dataid', item.GroupID);
                var td = $('<td>').text(item2.MenuName);
                tr2.append(td);
                td = $('<td>').text(item2.Path);
                tr2.append(td);
                td = $('<td style="text-align:center">');
                if (item2.View)
                    td.append('<i class="fa fa-lg fa-check-circle" style="color:green"></i>');
                tr2.append(td);
                td = $('<td style="text-align:center">');
                if (item2.AddNew)
                    td.append('<i class="fa fa-lg fa-check-circle" style="color:green"></i>');
                tr2.append(td);
                td = $('<td style="text-align:center">');
                if (item2.Edit)
                    td.append('<i class="fa fa-lg fa-check-circle" style="color:green"></i>');
                tr2.append(td);
                td = $('<td style="text-align:center">');
                if (item2.Delete)
                    td.append('<i class="fa fa-lg fa-check-circle" style="color:green"></i>');
                tr2.append(td);
                target.append(tr2);

            });
        });
    }

    function LoadData(page) {
        debugger;
        var numberinpage = 5;
        var keyword = "";
        var dataagr = JSON.stringify({
            keyword: keyword,
            currentpage: parseInt(page),
            numberinpage: numberinpage
        });
        LoadDataWithPaging($("#tablelistArticles > tbody"), $("#divpaging"), page, "POST", "/MainSys/ProcessAJAX/AjaxPower.aspx/GetListGroup", dataagr, LoadListArticles, numberinpage, LoadData);
    }


    $(document).ready(function () {
        debugger;
        LoadData(1);
    });
</script>
<section id="widget-grid" class="">
    <div class="row">
        <article class="col-sm-12 col-md-12 col-lg-12">

            <div class="alert alert-info alert-block">
                <h4 class="alert-heading" style="font-weight: bold">QUẢN LÝ PHÂN QUYỀN
        <label runat="server" id="lbOrg" style="font-weight: bold; display: inline;"></label>
                </h4>
            </div>

            <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-1" data-widget-editbutton="false" data-widget-fullscreenbutton="false">
                <header>
                    <h2>QUẢN LÝ PHÂN QUYỀN</h2>
                </header>

                <div class="widget-body widget-hide-overflow padding">
                    <div class="col-sm-12  smart-form">
                        <table id="tablelistArticles" class="table table-bordered">
                            <thead>
                                <tr>
                                    <th style="width: 150px; text-align: center">Control</th>
                                    <th>Path</th>
                                    <th style="width: 50px; text-align: center">View</th>
                                    <th style="width: 50px; text-align: center">Add New</th>
                                    <th style="width: 50px; text-align: center">Edit</th>
                                    <th style="width: 50px; text-align: center">Delete</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <div id="divpaging"></div>
                    </div>
                </div>
            </div>
        </article>
    </div>
</section>
